var windowWidth;
var windowHeight;
Component({
    properties:{},
    data:{
        buttonTop: 0,
        buttonLeft: 0
    },
    attached(){
        windowWidth = wx.getSystemInfoSync().windowWidth;
        windowHeight = wx.getSystemInfoSync().windowHeight;
        this.setData({
            buttonTop: windowHeight - 90,
            buttonLeft: windowWidth - 60
        });
    },
    methods:{
        buttonMove: function (e) {
            var endPoint = e.touches[e.touches.length - 1];
            var tempTop = 0;
            var tempLeft = 0;
            if (endPoint.clientY < 30) {
              tempTop = 0
            } else if (endPoint.clientY > windowHeight - 60) {
              tempTop = windowHeight - 60
            } else {
              tempTop = endPoint.clientY - 30
            }
            if (endPoint.clientX < 30) {
              tempLeft = 0
            } else if (endPoint.clientX > windowWidth - 60) {
              tempLeft = windowWidth - 60
            } else {
              tempLeft = endPoint.clientX - 30
            }
            this.setData({
              buttonTop: tempTop,
              buttonLeft: tempLeft
            })
          },
          buttonEnd: function (e) {
            var endPoint = e.changedTouches[0];
            // console.log("buttonEnd endPoint.clientY:" + endPoint.clientY);
            // console.log("buttonEnd endPoint.clientX:" + endPoint.clientX);
            var tempTop = 0;
            var tempLeft = 0;
            if (endPoint.clientY < 30) {
              tempTop = 0
            } else if (endPoint.clientY > windowHeight - 60) {
              tempTop = windowHeight - 60
            } else {
              tempTop = endPoint.clientY - 30
            }
            if (endPoint.clientX < 30) {
              tempLeft = 0
            } else if (endPoint.clientX > windowWidth - 60) {
              tempLeft = windowWidth - 60
            } else {
              tempLeft = endPoint.clientX - 30
            }
            // console.log("buttonEnd tempTop:" + tempTop);
            this.setData({
              buttonTop: tempTop,
              buttonLeft: tempLeft
            })
          }
    }
      
})